package javalearn;

import java.util.Objects;

class People {
    public String getName() {
        return name;
    }

    public People() {
        System.out.println("People()");
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    String name = "people";
    private String id;
    public void work(){

    }
    public void sleep(){
        System.out.println("sleep in bed");
    }
}

public class Student extends People {
    String name = "student";
    @Override
    public void sleep() {
        System.out.println("Student sleep in sushe");
    }

    public Student() {
        System.out.println("Student constructor");
    }

    static {
        System.out.println("静态Student constructor");
    }

    @Override
    public void work() {
        System.out.println("study");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }
}

